#ifndef _DATA_MAP_H_
#define	_DATA_MAP_H_

#include "stdint.h"

#ifdef	__cplusplus
extern "C" {
#endif

	typedef struct
	{
		uint8_t load_complete;   
		uint16_t load_mark[256]; 
		uint16_t block_total;
		uint16_t block_loaded;
		uint16_t block_load_now;
	}data_map_info_t;

	typedef const struct
	{
		uint32_t total_size;   
		uint32_t block_size;   
		uint32_t phy_addr_base;  
		uint32_t phy_erase_size;  
		uint8_t *map;          

		void(*phy_write)(uint32_t addr, uint8_t* dafa, uint32_t size);
		void(*phy_read)(uint32_t addr, uint8_t* dafa, uint32_t size);
		void(*phy_erase)(uint32_t addr);

		void(*mutex_take)(void);
		void(*mutex_release)(void);
		data_map_info_t * info;
	} data_map_t;

	uint8_t data_map_u8_read(data_map_t * pmap, uint32_t addr, uint8_t* dat, uint32_t size);
	uint8_t data_map_u16_read(data_map_t * pmap, uint32_t addr, uint16_t* dat, uint32_t size);
	uint8_t data_map_u32_read(data_map_t * pmap, uint32_t addr, uint32_t* dat, uint32_t size);
	uint8_t data_map_write(data_map_t * pmap, uint32_t addr, uint8_t* dat, uint32_t size);
	uint8_t data_map_erase(data_map_t * pmap, uint32_t addr);
	void data_map_load_poll(data_map_t * pmap);
	void data_map_init(data_map_t * pmap);

#ifdef	__cplusplus
}
#endif

#endif	

